/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ProtocolXML;

/**
 *
 * @author leshukov
 */
public class MyFilter implements FilterInter {

    private static String[] toDeny = { "БЛЯ", "ЕБА", "СУК", "ИДАР" } ;
    private final static String toReplace = "<font color=red>***</font>" ;
    public String sift( String message ) {
        String messageToSift = message ;
        String tempMessage  = messageToSift.toUpperCase() ;

        //
        for ( String deny : toDeny ) {
            int index ;
            while( ( index = tempMessage.lastIndexOf(deny) ) != -1 ) {
                String strBegin = messageToSift.substring( 0, index ) ;

                String strEnd = messageToSift.substring( index + deny.length() ) ;

                messageToSift = strBegin + toReplace + strEnd ;
                tempMessage = messageToSift.toUpperCase() ;
            }
        }
        return messageToSift ;
    }

}
